package com.sfx.admin.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sfx.admin.common.convention.result.Result;
import com.sfx.admin.common.convention.result.Results;
import com.sfx.admin.remote.ShortLinkActualRemoteService;
import com.sfx.admin.remote.dto.req.PageRecycleBinReqDTO;
import com.sfx.admin.remote.dto.req.RecoverRecycleBinReqDTO;
import com.sfx.admin.remote.dto.req.RemoveRecycleBinReqDTO;
import com.sfx.admin.remote.dto.req.SaveRecycleBinReqDTO;
import com.sfx.admin.remote.dto.resp.PageRecycleBinRespDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class RecycleBinController {

    private final ShortLinkActualRemoteService shortLinkActualRemoteService;


    @PostMapping("/api/short-link/admin/v1/recycle-bin/save")
    public Result<Void> saveRecycleBin(@RequestBody SaveRecycleBinReqDTO requestParam) {
        shortLinkActualRemoteService.saveRecycleBin(requestParam);
        return Results.success();
    }

    @GetMapping("/api/short-link/admin/v1/recycle-bin/page")
    public Result<Page<PageRecycleBinRespDTO>> pageRecycleBin(PageRecycleBinReqDTO requestParam) {
        return shortLinkActualRemoteService.pageRecycleBin(requestParam.getCurrent(),requestParam.getSize());
    }


    @PostMapping("/api/short-link/admin/v1/recycle-bin/recover")
    public Result<Void> recoverRecycleBin(@RequestBody RecoverRecycleBinReqDTO requestParam) {
        shortLinkActualRemoteService.recoverRecycleBin(requestParam);
        return Results.success();
    }


    @PostMapping("/api/short-link/admin/v1/recycle-bin/remove")
    public Result<Void> removeRecycleBin(@RequestBody RemoveRecycleBinReqDTO requestParam) {
        shortLinkActualRemoteService.removeRecycleBin(requestParam);
        return Results.success();
    }
}